﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Basmus.Values
{
    public static class BuilderExtensions
    {
        public static IBuilder<T> Cached<T>(this IBuilder<T> builder)
        {
            if (builder.GetType() == typeof(CachedBuilder<T>))
            {
                return builder;
            }
            return new CachedBuilder<T>(builder);
        }
        public static IBuilder<T> Composite<T>(this IEnumerable<IBuilder<T>> builders, Func<T, bool> predicate)
        {
            var compositeBuilder = new CompositeBuilder<T>(predicate, builders.ToArray());
            return compositeBuilder;
        }
    }
}